package Lobby;

import jHaggis.ModifiedFlowLayout;
import jHaggis.jHaggis;
import jHaggis.jTransPanel;
import jHaggis.jTransScrollPane;
import jHaggis.jTransTextArea;
import jHaggis.jWoodenButton;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Font;

import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.border.EmptyBorder;

/**
 * @author Christopher Vogel
 */
public class vLobby extends jHaggis {


	JButton btnLogout;
	JButton btnToplist;
	JButton btnCreateGame;
	JButton btnOpenRules;
	jTransTextArea wio_content;
	JPanel rooms;

	mLobby model;

	public static void main(String[] args) {
		mLobby model = new mLobby();
		vLobby view = new vLobby(model);
		new cLobby(model, view);
	}
/**
 * Konstruktor des Views der Lobby.
 * @param mLobby m
 * @author Christopher Vogel
 */
	public vLobby(mLobby m) {
		// Fenster erstellen:

		super("Haggis(TM) Lobby - powered by Future App Lab");
		this.model = m;
		this.setSize(1150, 650);
		Font InfoFont = new Font("Arial", Font.BOLD, 18);
		// Menu hinzufügen
		// this.setJMenuBar(new jGameRoomMenu());

		// Panel WEST_Pnael
		jTransPanel panel_west = new jTransPanel(new BorderLayout());
		panel_west.setBackground(Color.green);
		this.content.add(panel_west, BorderLayout.WEST);

		// Panel für Userinformationen
		jTransPanel user_panel = new jTransPanel();
		panel_west.add(user_panel, BorderLayout.NORTH);

		JLabel lbl_user = new JLabel();
		lbl_user.setText("Welcome "
				+ ServerListener.ServerListener.Player.getUserName() + "!");
		lbl_user.setFont(InfoFont);
		lbl_user.setForeground(Color.white);
		user_panel.add(lbl_user);

		// Panel für Usereinstellungen
		jTransPanel panel_settings = new jTransPanel(new ModifiedFlowLayout());
		panel_west.add(panel_settings, BorderLayout.CENTER);
		panel_settings.setPreferredSize(new Dimension(230, 100));

		btnLogout = new jWoodenButton("Logout");
		panel_settings.add(btnLogout);

		btnCreateGame = new jWoodenButton("Create New Game");
		panel_settings.add(btnCreateGame);
		// btn_create.setPreferredSize(ButtonSize);

		btnToplist = new jWoodenButton("Show Toplist");
		panel_settings.add(btnToplist);

		btnOpenRules = new jWoodenButton("Rulebook");
		panel_settings.add(btnOpenRules);

		// Panel für Who-is-online
		jTransPanel panel_who_is_online = new jTransPanel(new BorderLayout());
		JLabel wio_title = new JLabel("Who is currently online?", JLabel.CENTER);
		wio_title.setForeground(Color.white);
		panel_who_is_online.add(wio_title, BorderLayout.NORTH);
		wio_title.setFont(InfoFont);
		wio_content = new jTransTextArea(12, 15); // zeilen,
													// spalten
		wio_content.setFont(InfoFont);
		wio_content.setText("Loading players...");
		JScrollPane wio_content_scroll = new jTransScrollPane(wio_content);
		panel_who_is_online.add(wio_content_scroll);
		wio_content.setForeground(Color.white);
		panel_west.add(panel_who_is_online, BorderLayout.SOUTH);

		// Panel für Spielräume auswählen
		jTransPanel panel_east = new jTransPanel(new BorderLayout());

		this.content.add(panel_east, BorderLayout.CENTER);

		JPanel roomPanel = new jTransPanel(new FlowLayout());
		panel_east.add(roomPanel);
		rooms = new jTransPanel(new ModifiedFlowLayout());

		jTransScrollPane roomsScroll = new jTransScrollPane(rooms);

		roomsScroll.setPreferredSize(new Dimension(this.getWidth() - 290, this
				.getHeight() - 101));
		roomPanel.add(roomsScroll, BorderLayout.CENTER);

		JLabel footer = new JLabel(
				"Haggis(TM) powered by Future App Lab - all rights reserved -  \u00A9 COPYRIGHT by Future App Lab since 2014");
		footer.setForeground(Color.WHITE);
		footer.setBorder(new EmptyBorder(10, 5, 0, 0));
		this.content.add(footer, BorderLayout.SOUTH);

		this.setResizable(false);
		// this.pack();

		this.setVisible(true);
	}
}